$signup = $("#signup_button");

$(".signup_link").click(function(){
    $signup_scroll = $signup.offset().top;    
    $("html, body").animate({ scrollTop: $signup_scroll + "px" }, 1000, 'easeOutSine');
})

$('#faq_link').click(function(){
   $window = $(window).height(); 
    
   $("#homepage").animate({ top: $window + "px", opacity : 0 }, 1000, 'easeOutSine');
   $(".main_header").animate({ top: "-100px", opacity : 0 }, 1000, 'easeOutSine');
   $(".main_footer").fadeOut();
    
   setTimeout(function() {
        document.location.href='faq.html';
    }, 990);
})

function first_section() {
    $faded = $('.faded');
    $faded.each(function(index){  $(this).delay(350*index).animate({opacity: 1}, 900); });
    $("#net_right").animate({right : 0},1000);
    
    $("#mouse").delay(1800).animate({opacity:1},300).animate({opacity:0},300).animate({opacity:1},350).animate({opacity:0},400).animate({opacity:1},400);
    
    //second part
    
    $("#first_circle").delay(500).animate({borderWidth: 236}, 700, 'easeOutBounce');
    $("#second_circle").delay(700).animate({borderWidth: 175}, 700, 'easeOutBounce');
    $("#lines_second").delay(2000).fadeIn('slow');
    
    $("#first_circle_text").delay(1200).fadeIn(1000);
    $("#second_circle_text").delay(1200).fadeIn(1000);
}


$(window).load(function(){
    $("#loading").delay(400).fadeOut('700');
    first_section();
});

function network_section1() {
    $network = $("#network_color");
    $("#network_white").fadeOut(1000);
    
    /*$bubbles = $(".bubble");
    $bubbles.each(function(index){
                var wid = $(this).data("width");
                var heig = $(this).data("height");
                
                $(this).delay(1200*index).animate({ width : wid, height : heig},400 , "easeOutBounce");

            }); 
            
     $(".pre_footer img").delay(6000).animate({top: 0},800);  
     */
     
     $bubble1 = $('.bubble1');
     $bubble2 = $('.bubble2');
     
     var wid1 = $bubble1.data("width");
     var heig1 = $bubble1.data("height");
     
     var wid2 = $bubble2.data("width");
     var heig2 = $bubble2.data("height");
     
     $bubble1.animate({ width : wid1, height : heig1},400 , "easeOutBounce");
     $bubble2.delay(1200).animate({ width : wid2, height : heig2},400 , "easeOutBounce");
     
     $height = $('.bubble3').offset().top;
     
     $("#network_color").animate({height : '535px'}, 1500);
}

function network_section2() {
    
     $bubble1 = $('.bubble3');
     $bubble2 = $('.bubble4');
     
     var wid1 = $bubble1.data("width");
     var heig1 = $bubble1.data("height");
     
     var wid2 = $bubble2.data("width");
     var heig2 = $bubble2.data("height");
     
     $bubble1.animate({ width : wid1, height : heig1},400 , "easeOutBounce");
     $bubble2.delay(1200).animate({ width : wid2, height : heig2},400 , "easeOutBounce");
     
     $("#network_color").animate({height : '921px'}, 1500);
}

function network_section3() {
    
     $bubble1 = $('.bubble5');
     
     var wid1 = $bubble1.data("width");
     var heig1 = $bubble1.data("height");
     
     
     $bubble1.animate({ width : wid1, height : heig1},400 , "easeOutBounce");
     
     $("#network_color").animate({height : '1183px'}, 1500);
     
     $(".pre_footer img").delay(1500).animate({top: 0},800);  
}

$(window).scroll(function(){
    
    $circle = $("#whatis_circle");
    
    var scrll = $(this).scrollTop();
    var limit = $circle.offset().top - 500;
    
    var limit2 = $('.bubble3').offset().top - 500;
    
    var limit3 = $('.bubble5').offset().top - 500;
    
    if (scrll > limit && $circle.hasClass('trigger') ) {
        network_section1();
        $circle.removeClass('trigger');
    }   
      
    if (scrll > limit2 && $('.bubble3').hasClass('trigger') ) {
        network_section2();
        $('.bubble3').removeClass('trigger');
    }  
    
    if (scrll > limit3 && $('.bubble5').hasClass('trigger') ) {
        network_section3();
        $('.bubble5').removeClass('trigger');
    }
})


$(".signup_trigger").click(function () {
    $("#FBReg").css("visibility","hidden")
    $("#overlay").addClass("active_overlay");
    $id = $(this).attr("id");
    $("#" + $id + "_form").addClass("active_form");
    
});

$("#fb").click(function () {
    $("#FBReg").css("visibility", "visible")
    $("#overlay").addClass("active_overlay");
    $id = $(this).attr("id");
    $("#" + $id + "_form").addClass("active_form");
});




$("#overlay").bind('click', function (e) {
    
    $(".signup_form").removeClass("active_form");
    $("#overlay").removeClass("active_overlay");
});



$(".signup_form").bind('click', function(e) {
    e.stopPropagation();
});

$(".box").click(function(){
    $(this).toggleClass('checked');
    $(this).next('input[type=checkbox]').click();
})


/*******************************/
